#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>

int main(int argc,char* argv[])
{
  int tcp_fd = socket(AF_INET,SOCK_STREAM,0);
  if(tcp_fd < 0)
  {
    perror("socket fail");
    return -1;
  }

  struct sockaddr_in server_addr;
  server_addr.sin_port = htons(50000);
  server_addr.sin_family = AF_INET;
  
  socklen_t len = sizeof(server_addr);
  inet_pton(AF_INET,argv[1],&server_addr.sin_addr);
  
  int ret = connect(tcp_fd,(struct sockaddr*)&server_addr,len);

  char buf[1024];

  while(1)
  {
    printf("please input:");
    scanf("%s",buf);

    send(tcp_fd,buf,1024,0);
    if(!strcmp(buf,"bye"))
      break;
  }


  close(tcp_fd);
  return 0;
}
